package com.lingyun.mqttserver.util;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;

import java.util.HashMap;
import java.util.Map;

@Slf4j
public class JSONUtil {
    public static String toJSON(Map hashMap){
        try{
            return new ObjectMapper().writeValueAsString(hashMap);
        } catch (JsonProcessingException e) {
            log.error(e.getMessage() + "JSON解析错误");
            return "";
        }
    }
}
